package sqcon.sql;

public enum LogicOperator {
	AND ("AND"), 
	OR ("OR");
	
	private final String stringRep;
	
	LogicOperator(String stringRep){
		this.stringRep = stringRep;
	}
	
	public String printString(){
		return stringRep;
	}
	
	public static boolean isLogicOperator(String str){
		for(LogicOperator lo : LogicOperator.values()){
			if(lo.printString().equalsIgnoreCase(str)){
				return true;
			}
		}
		return false;
	}
	
	public static LogicOperator getLogicOperator(String opStr) 
			throws ConstructSqlException{
		if(opStr.equalsIgnoreCase(LogicOperator.AND.printString())){
			return LogicOperator.AND;
		}else if(opStr.equalsIgnoreCase(LogicOperator.OR.printString())){
			return LogicOperator.OR;
		}
		
		throw new ConstructSqlException("Invalid Logic Operator...");
	}
}
